package com.example.qing.service.aop;

import com.example.qing.config.Views;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class visitsAspect {
    @Autowired
    private RedisTemplate redisTemplate;


    @AfterReturning(pointcut = "@annotation(views)")
    public void visits(Views views){
       redisTemplate.opsForValue().increment("views");
        log.info("新增访问量");
    }


}
